package com.siao.mvc.notice
{
	import com.siao.mvc.core.INotice;
	import com.siao.mvc.core.IObserver;
	
	/**
	 * 观察者对象
	 * @author SiaoLeon
	 */
	public class Observer implements IObserver
	{
		// -------------------------------------------------------------------------------------------------------- 静态常量
		
		// -------------------------------------------------------------------------------------------------------- 静态变量
		
		// -------------------------------------------------------------------------------------------------------- 静态方法
		
		// -------------------------------------------------------------------------------------------------------- 静态函数
		
		// -------------------------------------------------------------------------------------------------------- 属性
		
		private var _object:Object;
		
		public function get object():Object
		{
			return this._object;
		}
		
		private var _callback:Function
		
		public function get callback():Function
		{
			return this._callback;
		}
		
		private var _priority:uint;
		
		public function get priority():uint
		{
			return this._priority;
		}
		
		// -------------------------------------------------------------------------------------------------------- 变量
		
		// -------------------------------------------------------------------------------------------------------- 构造
		
		/**
		 * 构造函数
		 */
		public function Observer(object:Object, callback:Function, priority:uint)
		{
			this._object = object;
			this._callback = callback;
			this._priority = priority;
		}
		
		// -------------------------------------------------------------------------------------------------------- 方法
		
		public function execute(notice:INotice):void
		{
			this.callback.call(this.object, notice);
		}
		
		public function equals(observer:IObserver):Boolean
		{
			return (this.object == observer.object && this.callback == observer.callback);
		}
	
		// -------------------------------------------------------------------------------------------------------- 函数
	
	}
}
